﻿
/*
 * jQuery placeholder, fix for IE6,7,8,9
 * @author JENA
 * @since 20131115.1504
 * @website ishere.cn
 */
var JPlaceHolder = {
    //检测
    _check : function(){
        return 'placeholder' in document.createElement('input');
    },
    //初始化
    init : function(){
        if(!this._check()){
            this.fix();
        }
    },
    //修复
    fix : function(){
        jQuery(':input[placeholder]').each(function(index, element) {
            var self = $(this), txt = self.attr('placeholder');
            self.wrap($('<div></div>').css({zoom:'1', border:'none', background:'none', padding:'none', margin:'none'}));
            var pos = self.position(), h = self.outerHeight(true), paddingleft = self.css('padding-left');
            var holder = $('<span></span>').text(txt).css({position:'absolute', left:pos.left+"px", top:pos.top+"px", height:h+"px", lineHeight:h+"px", paddingLeft:paddingleft+"px", color:'#aaa'}).appendTo(self.parent());
            self.focusin(function(e) {
                holder.hide();
            }).focusout(function(e) {
                if(!self.val()){
                    holder.show();
                }
            });
            holder.click(function(e) {
                holder.hide();
                self.focus();
            });
        });
    }
};
//执行
jQuery(function(){
    JPlaceHolder.init();    
});

$(function() {
	$("input[class*='btn'],a[class*='btn']").hover(function() {
		$(this).stop(true, true).animate({
			"opacity" : 0.5
		});
	}, function() {
		$(this).stop(true, true).animate({
			"opacity" : 1
		});
	});
	
	
	//回到顶部---------------
	$(".Sides_com_icon.icon3").click(function(){ 
		$('body,html').animate({scrollTop:0},1000); 
		return false; 
		});
	// 收益计算------------
	$(".profits").click(function() {
				var vel;
				var obj = $(this).parents(".Calculator");
				var is_day = parseInt(obj.find('input[name="typetime"]:checked').val());
				if(is_day == 0){
					//月
					vel = parseFloat(obj.find(".moneys").val()) * parseFloat(obj.find(".ratess").val())* parseFloat(obj.find(".terms").val()) / 1200;
				} else {
					//天
					vel = parseFloat(obj.find(".moneys").val()) * parseFloat(obj.find(".ratess").val())* parseFloat(obj.find(".terms").val()) / 36000;
				}
				if (vel > 0) {
					obj.find(".jiner").html(" 收益金额："+vel.toFixed(2));
				}
	  });

	
});

// index---------------------------------------------------------------------------------------------------
$(function() {

	 
//    try {
//        $(window).scroll(function () {
//            var wb = $(this).scrollTop() + $(this).height() - 10,
//            wt = $(this).scrollTop();
//            $(".progress:not([done='done'])").each(function () {
//                var _this = $(this).attr("done", "done");
//                _this.progress({stroke_bg: "#92c12f", loop: "#92c12f", stroke_width: 2 });
//            });
//        }).trigger("scroll");
//    } catch (e) { }
    try {
        $(window).scroll(function () {
            var wb = $(this).scrollTop() + $(this).height() - 10,
            wt = $(this).scrollTop();
            $(".progressinvest:not([done='done'])").each(function () {
                var _this = $(this).attr("done", "done");
                _this.progressinvest({stroke_bg: "#FF4500", loop: "#FF4500", stroke_width: 15 });
            });
        }).trigger("scroll");
    } catch (e) { }
	// 头部
	try {
		$(".hd").jslide({
			type : "slide",
			interval : 3000,
			selector : ".slides li",
			tabSel : ".bd li",
			tabClass : "current",
			rightBtn : ".rightBtn",
			leftBtn : ".leftBtn"
		});
	} catch (e) {
	}	
	 //懒加载图片
    $("img[data-original]").lazyload({ threshold: 100, failure_limit: 10, skip_invisible: false, effect: "fadeIn" });

});




$(function() {
	$(".inv_require_tab .nav").click(function() {
		var index = $(this).index();
		$(".inv_require_tab .nav").removeClass("sel");
		$(this).addClass("sel");
	});
	// 收益计算
	$(".profit").click(
			function() {
				var vel;
				var obj = $(this).parents(".inv_model");
				var is_day = parseInt(obj.find("input[name='is_day']").val());
				if(is_day == 0){
					vel = parseFloat(obj.find(".moneys").val()) * parseFloat(obj.find(".ratess").val())
					* parseFloat(obj.find(".terms").val()) / 1200;
				} else {
					vel = parseFloat(obj.find(".moneys").val()) * parseFloat(obj.find(".ratess").val())
					* parseFloat(obj.find(".terms").val()) / 36000;
				}
				var lixi;
				if(is_day == 0){
					lixi = parseFloat(obj.find(".moneys").val()) * parseFloat(obj.find(".ratess").val()) / 1200;
				} else {
					lixi = parseFloat(obj.find(".moneys").val()) * parseFloat(obj.find(".ratess").val()) / 36000;
				}
				var yinhuan = lixi + (parseFloat(obj.find(".moneys").val()) / parseFloat(obj.find(".terms").val()));
				if (vel > 0) {
					obj.find(".xinxi").val(vel.toFixed(2));
				}
			});

});

// invest_d------------------------------------------------------------------------------------------------------------
$(function() {
	$("#invd_con_tit li").click(function() {
		var index = $(this).index();
		$(this).addClass("sel").siblings().removeClass("sel");
		$(".invd_model").eq(index).show().siblings(".invd_model").hide();
	});
	$(".endtime").each(
			function() {
				var _this = $(this);
				console.log(_this.text());
				//var iTime = parseInt(_this.text()) - (Date.parse(new Date()) / 1000);
				//dd = parseInt(iTime / 24 / 3600);
				//hh = parseInt((iTime / 3600) % 24);
				//mm = parseInt((iTime / 60) % 60);
				//ss = parseInt(iTime % 60);
                //
				//_this.html([ dd, "天", (hh < 10 ? "0" + hh : hh), "小时", (mm < 10 ? "0" + mm : mm), "分",
				//		(ss < 10 ? "0" + ss : ss), "秒" ].join(""));
				setInterval(function() {
					iTime--;
					dd = parseInt(iTime / 24 / 3600);
					hh = parseInt((iTime / 3600) % 24);
					mm = parseInt((iTime / 60) % 60);
					ss = parseInt(iTime % 60);

					_this.html([ dd, "天", (hh < 10 ? "0" + hh : hh), "小时", (mm < 10 ? "0" + mm : mm), "分",
							(ss < 10 ? "0" + ss : ss), "秒" ].join(""));
				}, 1000);

			});

	
	
});
